home *** CD-ROM | disk | FTP | other *** search
/ WINMX Assorted Textfiles / Ebooks.tar / Text - Tech - Hacking - PKZip password hacking (TXT).rar / zippass.txt
Text File  |  2003-09-28  |  6KB  |  165 lines

  1. Article 357 of sci.crypt:
  2. Xref: vpnet comp.compression:174 sci.crypt:357
  3. Path: vpnet!tellab5!laidbak!ism.isc.com!ispd-newsserver!rpi!crdgw1!uunet!maverick.ksu.ksu.edu!matt.ku.edu!parsons
  4. From: parsons@matt.ksu.ksu.edu (Ghost in the Machine)
  5. Newsgroups: comp.compression,sci.crypt
  6. Subject: Re: Security of PKZIP's encryption
  7. Message-ID: <1991Apr2.070810.10812@maverick.ksu.ksu.edu>
  8. Date: 2 Apr 91 07:08:10 GMT
  9. References: <1991Mar26.150049.20882@athena.cs.uga.edu>
  10. Sender: news@maverick.ksu.ksu.edu (The News Guru)
  11. Organization: Kansas State University
  12. Lines: 135
  13.  
  14. is@athena.cs.uga.edu (Bob Stearns) writes:
  15.  
  16. >While I commonly recommend PKZIP (tm) for saving space on a hard disk, I have
  17. >been asked how strong its encryption (-spassword) option is. I have no way of
  18. >testing this and wonder if anyone out there in net land has investigated it.
  19. >If you have investigated the actual code and can explain the general algorithm
  20. >I can form my own opinion of its strength.
  21.  
  22. Here's what I found floating around on my roomates computer in the 
  23. PKzip archive file.  This should help you to pass judgement on the security
  24. of the password encryption.
  25.  
  26. DISCLAIMER:  This is part of the application notes for PKZIP.  Much
  27. has been deleted about the actual compression algorithm, and only the
  28. relevent part about password encryption remains.
  29.  
  30.  
  31. Decryption
  32. ----------
  33.  
  34. The encryption used in PKZIP was generously supplied by Roger
  35. Schlafly.  PKWARE is grateful to Mr. Schlafly for his expert
  36. help and advice in the field of data encryption.
  37.  
  38. PKZIP encrypts the compressed data stream.  Encrypted files must
  39. be decrypted before they can be extracted.
  40.  
  41. Each encrypted file has an extra 12 bytes stored at the start of
  42. the data area defining the encryption header for that file.  The
  43. encryption header is originally set to random values, and then
  44. itself encrypted, using 3, 32-bit keys.  The key values are 
  45. initialized using the supplied encryption password.  After each byte
  46. is encrypted, the keys are then updated using psuedo-random number
  47. generation techniques in combination with the same CRC-32 algorithm 
  48. used in PKZIP and described elsewhere in this document.
  49.  
  50. The following is the basic steps required to decrypt a file:
  51.  
  52. 1) Initialize the three 32-bit keys with the password.
  53. 2) Read and decrypt the 12-byte encryption header, further
  54.    initializing the encryption keys.
  55. 3) Read and decrypt the compressed data stream using the
  56.    encryption keys.
  57.  
  58.  
  59. Step 1 - Initializing the encryption keys
  60. -----------------------------------------
  61.  
  62. Key(0) <- 305419896
  63. Key(1) <- 591751049
  64. Key(2) <- 878082192
  65.  
  66. loop for i <- 0 to length(password)-1
  67.     update_keys(password(i))
  68. end loop
  69.  
  70.  
  71. Where update_keys() is defined as:
  72.  
  73.  
  74. update_keys(char):
  75.   Key(0) <- crc32(key(0),char)
  76.   Key(1) <- Key(1) + (Key(0) & 000000ffH)
  77.   Key(1) <- Key(1) * 134775813 + 1
  78.   Key(2) <- crc32(key(2),key(1) >> 24)
  79. end update_keys
  80.  
  81.  
  82. Where crc32(old_crc,char) is a routine that given a CRC value and a 
  83. character, returns an updated CRC value after applying the CRC-32 
  84. algorithm described elsewhere in this document.
  85.  
  86.  
  87. Step 2 - Decrypting the encryption header
  88. -----------------------------------------
  89.  
  90. The purpose of this step is to further initialize the encryption
  91. keys, based on random data, to render a plaintext attack on the
  92. data ineffective.
  93.  
  94.  
  95. Read the 12-byte encryption header into Buffer, in locations
  96. Buffer(0) thru Buffer(11).
  97.  
  98. loop for i <- 0 to 11
  99.     C <- buffer(i) ^ decrypt_byte()
  100.     update_keys(C)
  101.     buffer(i) <- C
  102. end loop
  103.  
  104.  
  105. Where decrypt_byte() is defined as:
  106.  
  107.  
  108. unsigned char decrypt_byte()
  109.     local unsigned short temp
  110.     temp <- Key(2) | 2
  111.     decrypt_byte <- (temp * (temp ^ 1)) >> 8
  112. end decrypt_byte
  113.  
  114.  
  115. After the header is decrypted, the last two bytes in Buffer
  116. should be the high-order word of the CRC for the file being
  117. decrypted, stored in Intel low-byte/high-byte order.  This can
  118. be used to test if the password supplied is correct or not.
  119.  
  120.  
  121. Step 3 - Decrypting the compressed data stream
  122. ----------------------------------------------
  123.  
  124. The compressed data stream can be decrypted as follows:
  125.  
  126.  
  127. loop until done
  128.     read a charcter into C
  129.     Temp <- C ^ decrypt_byte()
  130.     update_keys(temp)
  131.     output Temp
  132. end loop
  133.  
  134.  
  135. In addition to the above mentioned contributors to PKZIP and PKUNZIP, 
  136. I would like to extend special thanks to Robert Mahoney for suggesting 
  137. the extension .ZIP for this software.
  138.  
  139.  
  140. References:
  141.  
  142.     Storer, James A. "Data Compression, Methods and Theory",
  143.        Computer Science Press, 1988
  144.     
  145.     Held, Gilbert  "Data Compression, Techniques and Applications,
  146.             Hardware and Software Considerations"
  147.        John Wiley & Sons, 1987
  148.  
  149.  
  150.  
  151.  
  152. X-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-X
  153.  Another file downloaded from:                     The NIRVANAnet(tm) Seven
  154.  
  155.  & the Temple of the Screaming Electron   Taipan Enigma        510/935-5845
  156.  Burn This Flag                           Zardoz               408/363-9766
  157.  realitycheck                             Poindexter Fortran   510/527-1662
  158.  Lies Unlimited                           Mick Freen           801/278-2699
  159.  The New Dork Sublime                     Biffnix              415/864-DORK
  160.  The Shrine                               Rif Raf              206/794-6674
  161.  Planet Mirth                             Simon Jester         510/786-6560
  162.  
  163.                           "Raw Data for Raw Nerves"
  164. X-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-X
  165.